﻿<?php
/*
Template Name: Ings
*/
?>
<?php get_header(); ?>
<div id="contentarea">
	<div class="wide">
		<?php include (TEMPLATEPATH . '/ing.php'); ?>
		<div class="postinfo">
			<h2>iHao Ings List</h2><a href="http://api.fanfou.com/statuses/user_timeline/ihao.rss" title="iHao's Ings FEED">FEED</a>
		</div>
			<ol>
				<?php
					require_once (ABSPATH . WPINC . '/rss.php');
					$feed_url = 'http://api.fanfou.com/statuses/user_timeline.rss?id=ihao&count=20';
					$rss = @fetch_rss($feed_url);	
					if ( isset($rss->items) && 0 < count($rss->items) ) { 
						$rss->items = array_slice($rss->items, 0, 20);
						foreach ($rss->items as $item ) {
							$ihao_ing = preg_replace( '|ihao：(.+)?|s', '$1', $item['title'] );?>
							<li><a href="<?php echo $item['link']; ?>"><?php echo $ihao_ing; ?></a> &raquo; <?php printf(__('%s ago'), human_time_diff(strtotime($item['pubdate'], time() ) ) ); ?></li>
				<?php } } ?>
			</ol>
	</div>
	<?php get_sidebar(); ?>
</div>
<?php get_footer(); ?>